<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
		<style>
			.box {
				width: 200px;
				height: 30px;
			}
		</style>
	</head>

	<body>
		<h3>标题1</h3>

		<div class="box">123</div>
		<div class="box">abc</div>
		<p id="nav">导航栏</p>
		<ul class="nav">
			<li>首页</li>
			<li>地图</li>
			<li>音乐</li>
			<li>游戏</li>
		</ul>
		<script>
			// 1. 获取匹配的第一个元素
			// h3 div p li
			console.log(document.querySelector("h3"));
			console.log(document.querySelector("div"));
			console.log(document.querySelector("p"));
			console.log(document.querySelector("li"));

			// 2. 选择所有的小li
			console.log(document.querySelectorAll("li"));

			// 3.遍历获取li具体元素
			let liNodeList = document.querySelectorAll("li");
			liNodeList.forEach((element) => {
				console.log(element);
			});
		</script>
	</body>
</html>
